<template>
	<view>
		<u-toast :position="'top'" ref="uToast" />
		<u-modal ref="uModal" v-model="message.show" :show-cancel-button="true" :title="message.title"
			:show-title="true" @confirm="onConfirm" @cancel="onCancel" :content="message.content"> </u-modal>
		<slot></slot>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				message: {
					show: false,
					content: '',
					title: '',
					onconfirm: () => {

					}
				}
			}
		},
		methods: {
			confirm(onconfirm = () => {}, msg = '确定此操作吗？', title = '系统提示') {
				this.message.onconfirm = onconfirm;
				this.message.title = title;
				this.message.content = msg;
				this.message.show = true
			},
			onConfirm() {
				this.message.show = false
				this.message.onconfirm();
			},
			onCancel() {
				this.message.show = false
			},
			toast(msg = '操作成功', type = 'success',position='top') {
				this.$refs.uToast.show({
					title: msg,
					type,
					position
				})
			}
		}
	}
</script>

<style lang="scss" scoped>

</style>
